package com.xuecheng.system.controller;


import com.xuecheng.commons.model.vo.AuthInfo;
import com.xuecheng.commons.model.vo.CompanyVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.commons.utils.AuthInfoHolder;
import com.xuecheng.commons.utils.BeanHelper;
import com.xuecheng.system.domain.Company;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xuecheng.system.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 教育机构前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
@RequestMapping("/company")
public class CompanyController {

    @Autowired
    private CompanyService  companyService;


    @GetMapping("/mine")
    public ResponseResult mine(){
        //从线程中获取用户数据
        AuthInfo info = AuthInfoHolder.getAuthInfo();
        //调用service,查询数据
        Company company = companyService.getById(info.getCompanyId());
        //返回数据,BeanHelper只能处理同名同类型的数据
        CompanyVo vo = BeanHelper.copyProperties(company, CompanyVo.class);  //BeanHelper.copyProperties(原数据,返回数据)
        return ResponseResult.okResult(vo);
    }
}
